package com.bauer.java.sharding.spring;

import com.bauer.java.sharding.base.RawJdbcRepository;
import io.shardingjdbc.core.api.ShardingDataSourceFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.sql.DataSource;

public class SpringMain {

    private static Logger logger = LoggerFactory.getLogger(SpringMain.class);

    public static void main(String[] args) throws Exception {
        ApplicationContext ctx=new ClassPathXmlApplicationContext("spring/sharding-datasource.xml");
        RawJdbcRepository rawJdbcRepository = new RawJdbcRepository((DataSource) ctx.getBean("shardingDataSource"));
        rawJdbcRepository.demo();
    }
}
